package com.xjrsoft.module.customerTwo.EMP.total_water_and_electricity_expenses.controller;

import cn.dev33.satoken.annotation.SaCheckPermission;
import cn.dev33.satoken.annotation.SaMode;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.xjrsoft.common.page.PageOutput;
import com.xjrsoft.common.page.ConventPage;
import java.util.List;
import com.xjrsoft.common.result.Response;
import com.xjrsoft.core.tool.utils.BeanUtil;
import com.xjrsoft.module.customerTwo.EMP.total_water_and_electricity_expenses.dto.Table65204792021317750000Dto;
import com.xjrsoft.module.customerTwo.EMP.total_water_and_electricity_expenses.dto.SaveTable65204792021317750000FormDataDto;
import com.xjrsoft.module.customerTwo.EMP.total_water_and_electricity_expenses.vo.Table65204792021317750000Vo;
import com.xjrsoft.module.customerTwo.EMP.total_water_and_electricity_expenses.vo.Table65204792021317750000ListVo;
import com.xjrsoft.module.customerTwo.EMP.total_water_and_electricity_expenses.dto.Table65204792021317750000ListDto;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import lombok.AllArgsConstructor;

import org.springframework.web.bind.annotation.*;
import com.xjrsoft.module.customerTwo.EMP.total_water_and_electricity_expenses.entity.Table65204792021317750000;
import com.xjrsoft.module.customerTwo.EMP.total_water_and_electricity_expenses.vo.Table65204792021317750000Vo;
import com.xjrsoft.module.customerTwo.EMP.total_water_and_electricity_expenses.service.ITable65204792021317750000Service;

/**
 *  控制器
 *
 * @author system
 * @since 2023-12-07
 */
@RestController
@AllArgsConstructor
@RequestMapping("/total_water_and_electricity_expenses")
@Api(value = "水电费合计", tags = "水电费合计接口")
public class Table65204792021317750000Controller {


	private final ITable65204792021317750000Service table65204792021317750000Service;


	/**
	 * 详情 
	 */
	@GetMapping("/{id}")
	@ApiOperation(value = "详情", notes = "传入table65204792021317750000")
	@SaCheckPermission(value = {"total_water_and_electricity_expenses:view", "total_water_and_electricity_expenses:modify"}, mode = SaMode.OR)
	public Response<Table65204792021317750000Vo> getFormData(@PathVariable String id) {
		// 主表数据
		Table65204792021317750000 table65204792021317750000 = table65204792021317750000Service.getById(id);
		Table65204792021317750000Vo table65204792021317750000Vo = BeanUtil.copy(table65204792021317750000, Table65204792021317750000Vo.class);
		return Response.ok(table65204792021317750000Vo);
	}

	/**
	 * 自定义分页 
	 */
	@GetMapping
	@ApiOperation(value = "分页", notes = "传入table65204792021317750000")
		public Response<PageOutput<Table65204792021317750000ListVo>> getPageList(Table65204792021317750000ListDto listDto) {
		IPage<Table65204792021317750000> page = table65204792021317750000Service.getPageList(listDto);
		List<Table65204792021317750000ListVo> records = BeanUtil.copyList(page.getRecords(), Table65204792021317750000ListVo.class);
		return Response.ok(ConventPage.getPageOutput(page.getTotal(), records));
	}

	/**
	 * 新增 
	 */
	@PostMapping
	@ApiOperation(value = "新增", notes = "传入table65204792021317750000")
	@SaCheckPermission("total_water_and_electricity_expenses:add")
	public Response save(@RequestBody SaveTable65204792021317750000FormDataDto formDto) {
		Table65204792021317750000Dto table65204792021317750000Dto = formDto.getTable65204792021317750000Dto();
		Table65204792021317750000 table65204792021317750000 = BeanUtil.copy(table65204792021317750000Dto, Table65204792021317750000.class);
		boolean isSuccess = table65204792021317750000Service.addTable65204792021317750000(table65204792021317750000);
		return Response.status(isSuccess);
	}

	/**
	 * 修改 
	 */
	@PutMapping("/{id}")
	@ApiOperation(value = "修改", notes = "传入table65204792021317750000")
	@SaCheckPermission("total_water_and_electricity_expenses:modify")
	public Response update(@PathVariable String id, @RequestBody SaveTable65204792021317750000FormDataDto formDto) {
		Table65204792021317750000Dto table65204792021317750000Dto = formDto.getTable65204792021317750000Dto();
		Table65204792021317750000 table65204792021317750000 = BeanUtil.copy(table65204792021317750000Dto, Table65204792021317750000.class);
		return Response.status(table65204792021317750000Service.updateTable65204792021317750000(id, table65204792021317750000));
	}



	/**
	 * 删除 
	 */
	@DeleteMapping("/{ids}")
	@ApiOperation(value = "删除", notes = "传入ids")
	@SaCheckPermission(value = {"total_water_and_electricity_expenses:batchDelete", "total_water_and_electricity_expenses:delete"}, mode = SaMode.OR)
	public Response remove(@ApiParam(value = "主键集合", required = true) @PathVariable String ids) {
		return Response.status(table65204792021317750000Service.delete(ids));
	}


}
